home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / iutil / del_tuple.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  1006 b   |  52 lines

  1. # include    <ingres.h>
  2. # include    <access.h>
  3. # include    <sccs.h>
  4.  
  5. SCCSID(@(#)del_tuple.c    8.1    12/31/84)
  6.  
  7. /*
  8. **    Delete the specified tuple from the
  9. **    current page.
  10. **
  11. **    The space occupied by the tuple is
  12. **    compacted and the effected remaining
  13. **    tuple line offsets are adjusted.
  14. */
  15.  
  16. del_tuple(tid, width)
  17. TID    *tid;
  18. int    width;
  19. {
  20.     register char    *startpt, *midpt;
  21.     register int    i;
  22.     extern char    *get_addr();
  23.     char        *endpt;
  24.     int        cnt, offset, nextline;
  25.     int        linenum;
  26.  
  27.     linenum = tid->line_id & I1MASK;
  28.     offset = Acc_head->linetab[-linenum];
  29.     nextline = Acc_head->nxtlino;
  30.  
  31.     startpt = get_addr(tid);
  32.     midpt = startpt + width;
  33.     endpt = (char *)Acc_head + Acc_head->linetab[-nextline];
  34.  
  35.     cnt = endpt - midpt;
  36.  
  37.     /* delete tuple */
  38.     Acc_head->linetab[-linenum] = 0;
  39.  
  40.     /* update affected line numbers */
  41.     for (i = 0; i <= nextline; i++)
  42.     {
  43.         if (Acc_head->linetab[-i] > offset)
  44.             Acc_head->linetab[-i] -= width;
  45.     }
  46.  
  47.     /* compact the space */
  48.     while (cnt--)
  49.         *startpt++ = *midpt++;
  50.     Acc_head->bufstatus |= BUF_DIRTY;
  51. }
  52.